package com.open4cn.simulator.parser.huagao;

import cn.hutool.core.util.HexUtil;
import com.open4cn.simulator.core.answer.AbstractAnswer;
import com.open4cn.simulator.core.ext.HuaGaoOutMessage;
import com.open4cn.simulator.core.parser.IInstructionParser;
import com.open4cn.simulator.core.parser.InstructionParserChain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @author yinxiaopeng
 * @version 1.0.0
 * @company 致景科技
 * @department 飞梭BU/研发
 * @description
 * @Email yinxiaopeng@zj.tech
 * @date 2022-05-08 19:15
 */
public class HGUnknown implements IInstructionParser {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    // 收到通知(ACK)
    public static final String ACK = "06";
    // 正文结束(ETX)
    public static final String ETX = "03";

    @Override
    public Object parse(Object msg, InstructionParserChain chain) {
        logger.error("无法识别指令{}", msg);
        String msgHex = ACK + HexUtil.encodeHexStr("error") + ETX;
        return new HuaGaoOutMessage(msgHex);
    }

    @Override
    public List<AbstractAnswer> getAnswers() {
        return null;
    }
}
